home *** CD-ROM | disk | FTP | other *** search
/ Download Now 8 / Download Now V8.iso / Program / InternetTools / ApacheWebServer1.3.6 / apache_1_3_6_win32.exe / _SETUP.1 / mkh < prev    next >
Encoding:
Text File  |  1998-07-09  |  1.9 KB  |  78 lines

  1. #! /bin/sh
  2. # mkh - pull headers out of C source
  3.  
  4. # egrep pattern to pick out marked lines
  5. egrep='^ =([     ]|$)'
  6.  
  7. # Sed program to process marked lines into lines for the header file.
  8. # The markers have already been removed.  Two things are done here:  removal
  9. # of backslashed newlines, and some fudging of comments.  The first is done
  10. # because -o needs to have prototypes on one line to strip them down.
  11. # Getting comments into the output is tricky; we turn C++-style // comments
  12. # into /* */ comments, after altering any existing */'s to avoid trouble.
  13. peel='    /\\$/N
  14.     /\\\n[     ]*/s///g
  15.     /\/\//s;\*/;* /;g
  16.     /\/\//s;//\(.*\);/*\1 */;'
  17.  
  18. for a
  19. do
  20.     case "$a" in
  21.     -o)    # old (pre-function-prototype) compiler
  22.         # add code to comment out argument lists
  23.         peel="$peel
  24.             "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);'
  25.         shift
  26.         ;;
  27.     -b)    # funny Berkeley __P macro
  28.         peel="$peel
  29.             "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));'
  30.         shift
  31.         ;;
  32.     -s)    # compiler doesn't like `static foo();'
  33.         # add code to get rid of the `static'
  34.         peel="$peel
  35.             "'/^static[     ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;'
  36.         shift
  37.         ;;
  38.     -p)    # private declarations
  39.         egrep='^ ==([     ]|$)'
  40.         shift
  41.         ;;
  42.     -i)    # wrap in #ifndef, argument is name
  43.         ifndef="$2"
  44.         shift ; shift
  45.         ;;
  46.     *)    break
  47.         ;;
  48.     esac
  49. done
  50.  
  51. echo "/* DON'T EVEN THINK ABOUT EDITING THIS, go see regex/Makefile,"
  52. echo " * search for mkh */"
  53. if test " $ifndef" != " "
  54. then
  55.     echo "#ifndef $ifndef"
  56.     echo "#define    $ifndef    /* never again */"
  57. fi
  58. echo "/* ========= begin header generated by $0 ========= */"
  59. echo '#ifdef __cplusplus'
  60. echo 'extern "C" {'
  61. echo '#endif'
  62. for f
  63. do
  64.     echo
  65.     echo "/* === $f === */"
  66.     egrep "$egrep" $f | sed 's/^ ==*[     ]//;s/^ ==*$//' | sed "$peel"
  67.     echo
  68. done
  69. echo '#ifdef __cplusplus'
  70. echo '}'
  71. echo '#endif'
  72. echo "/* ========= end header generated by $0 ========= */"
  73. if test " $ifndef" != " "
  74. then
  75.     echo "#endif"
  76. fi
  77. exit 0
  78.